# -*- coding: utf-8 -*-
import sys
import logging
import sqlalchemy
from lxml import etree
from xadmin.model import *
from xadmin.lib.base import *
from xadmin.lib.trazabilityfactory import TrazabilityFactory

class TrazabilityController(BaseController):
    """REST Controller styled on the Atom Publishing Protocol"""
    # To properly map this controller, ensure your config/routing.py file has
    # a resource setup:
    #     map.resource('traza', 'trazability')


    def index(self, format='html'):
        """GET /trazability: All items in the collection."""
        # url_for('trazability')
        pass

    def listByProjectType(self, project, type):
        """GET /trazability: All items in the collection."""
        # url_for('trazability')
        response.headers['Content-Type'] = 'text/xml; charset=utf-8'
        res = TrazabilityFactory().getInstance(type).getTrazaByProject(project)
        if res is not None:
            return res
        else:
            abort(404)

    def create(self):
        """POST /trazability: Create a new item."""
        # url_for('trazability')
        pass

    def new(self, format='html'):
        """GET /trazability/new: Form to create a new item."""
        # url_for('new_traza')
        pass

    def update(self, id):
        """PUT /trazability/id: Update an existing item."""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="PUT" />
        # Or using helpers:
        #    h.form(h.url_for('traza', id=ID),
        #           method='put')
        # url_for('traza', id=ID)
        pass

    def delete(self, id):
        """DELETE /trazability/id: Delete an existing item."""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="DELETE" />
        # Or using helpers:
        #    h.form(h.url_for('traza', id=ID),
        #           method='delete')
        # url_for('traza', id=ID)
        pass

    def show(self, id, format='html'):
        """GET /trazability/id: Show a specific item."""
        # url_for('traza', id=ID)
        pass

    def edit(self, id, format='html'):
        """GET /trazability/id;edit: Form to edit an existing item."""
        # url_for('edit_traza', id=ID)
        pass
